package com.boyuan.huijiaoyu;

import cn.jpush.android.api.JPushInterface;

import com.boyuan.huijiaoyu.R;
import com.nostra13.universalimageloader.core.ImageLoader;

import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
import android.os.Handler;
import android.widget.TextView;

public class SplashActivity extends Activity {

	private final int SPLASH_DISPLAY_LENGHT = 3000; // 延迟三秒
	private TextView versionView;
	protected ImageLoader imageLoader = ImageLoader.getInstance();
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		setContentView(R.layout.splash);
		
		imageLoader.clearMemoryCache();
		imageLoader.clearDiskCache();

		PackageManager pm = getPackageManager();
		try {
			PackageInfo pi = pm.getPackageInfo("com.boyuan.huijiaoyu", 0);
			versionView = (TextView) findViewById(R.id.versionNumber);
			versionView.setText(getResources().getString(R.string.vision)// 版本
					+ pi.versionName);
		} catch (NameNotFoundException e) {
			e.printStackTrace();
		}

		new Handler().postDelayed(new Runnable() {
			public void run() {

				// int isShowIntro = SharePreferenceHelper.getIntValue(
				// getApplicationContext(), SharePreferenceHelper.INTRO);
//				int isShowIntro = 1;


				//				if (isShowIntro == 0) {
//
//					Intent introIntent = new Intent(SplashActivity.this,
//							IntroActivity.class);
//					startActivity(introIntent);
//					finish();
//				} else {
//					Intent mainIntent = new Intent(SplashActivity.this,
//							MainActivity.class);
//					startActivity(mainIntent);
//					finish();
//				}
				Intent intent = new Intent(SplashActivity.this,AccountLoginActivity.class);
				startActivity(intent);
				finish();

			}
		}, SPLASH_DISPLAY_LENGHT);

	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();

		JPushInterface.onResume(this);
	}

	@Override
	protected void onPause() {
		// TODO Auto-generated method stub
		super.onPause();

		JPushInterface.onPause(this);
	}

}
